/**
*      author: Y_Yao
*      created: 2024-10-05 20:49:42
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const int INF = 0x3f3f3f3f;
const int N = 50 + 9;
int a[N];

void solve()
{
    int n,k;
    cin >> n >> k;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }

    int hand = 0;
    int ret = 0;
    for(int i = 0;i < n;i++)
    {
        if(a[i] >= k) hand += a[i];
        else if(a[i] == 0 && hand >= 1)
        {
            hand--;
            ret++;
        }
    }
    cout << ret << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}